/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gr.uop.cst.context.adaptation;

import java.io.*;

/**
 *
 * @author jbourlakos
 */
public class ContextRuleInputStream extends ObjectInputStream {
    
    private String filename;
    private InputStream inputStream;
    
    public ContextRuleInputStream(String filename) throws FileNotFoundException, IOException {
        this(new FileInputStream(filename));
        this.filename = filename;
    }
    
    public ContextRuleInputStream(InputStream is) throws IOException {
        super(is);
        this.inputStream = is;
    }
    
    public ContextRule readContextRule() throws ClassNotFoundException, EOFException, IOException {
        Object o = this.readObject();
        if (!(o instanceof ContextRule)) throw new IOException("Read object is not a ContextRule.");
        return (ContextRule)o;
    }
    
    public String getFilename() {
        return this.filename;
    }
}
